package com.utils;

import java.io.File;

public class DiskSpaceUtil {
	public DiskSpaceUtil() {
	}

//	public static void main(String[] args) {
//		testDisk("D:/d/d/");
//	}
	public StringBuffer testDisk(String diskPath) {
		StringBuffer stringBuffer = new StringBuffer(50);
		if (diskPath.length()>=3){

			System.out.println(diskPath.substring(0,3));
		}
		File file = new File(diskPath);
		long totalSpace = file.getTotalSpace();
		long freeSpace = file.getFreeSpace();
		long usedSpace = totalSpace - freeSpace;
//
//		System.out.println("总空间大小 : " + totalSpace / 1024 / 1024 / 1024 + "G"+"\n");
//		System.out.println("剩余空间大小 : " + freeSpace / 1024 / 1024 / 1024 + "G"+"\n");
//		System.out.println("已用空间大小 : " + usedSpace / 1024 / 1024 / 1024 + "G"+"\n");

//		stringBuffer.append("总空间大小 : " + totalSpace / 1024 / 1024 / 1024 + "G"+"\n");
		stringBuffer.append("剩余空间大小 : " + freeSpace / 1024 / 1024 / 1024 + "G"+"\n");
		stringBuffer.append("已用空间大小 : " + usedSpace / 1024 / 1024 / 1024 + "G"+"\n");
		return stringBuffer;
	}

}
